package com.imay.live.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.imay.live.adapter.RankingAdapter;

/**
 * Created by  nick on 2017/4/20 0020.
 * 排行榜
 */

public class RankingModel implements MultiItemEntity,Parcelable{

    private UserModel user;
    private long value;
    private int rank;
    private String rankType;

    public RankingModel() {
        super();
    }

    protected RankingModel(Parcel in) {
        user = in.readParcelable(UserModel.class.getClassLoader());
        value = in.readLong();
        rank = in.readInt();
        rankType = in.readString();
    }

    public static final Creator<RankingModel> CREATOR = new Creator<RankingModel>() {
        @Override
        public RankingModel createFromParcel(Parcel in) {
            return new RankingModel(in);
        }

        @Override
        public RankingModel[] newArray(int size) {
            return new RankingModel[size];
        }
    };

    public UserModel getUser() {
        return user;
    }

    public void setUser(UserModel user) {
        this.user = user;
    }

    public long getValue() {
        return value;
    }

    public void setValue(long value) {
        this.value = value;
    }

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        this.rank = rank;
    }

    public String getRankType() {
        return rankType;
    }

    public void setRankType(String rankType) {
        this.rankType = rankType;
    }

    @Override
    public int getItemType() {
        switch (rank) {
            case 0:
                return RankingAdapter.ITEM_TYPE_FIRST;
            case 1:
            case 2:
                return RankingAdapter.ITEM_TYPE_SECOND;
            default:
                return RankingAdapter.ITEM_TYPE_NORMAL;
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(user, flags);
        dest.writeLong(value);
        dest.writeInt(rank);
        dest.writeString(rankType);
    }
}
